package com.example.demo.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName WebMvcInterceptorConfig
 * @Description: 修改请联系我，否则请勿随意修改
 * @Author ChenYuan
 * @Date 2021/4/30
 * @Version V1.0
 **/
@Component
public class WebMvcInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private TestInterceptor1 testInterceptor1;

    @Autowired
    private TestInterceptor2 testInterceptor2;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册顺序就是执行顺序
        registry.addInterceptor(testInterceptor2).addPathPatterns("/**");

        registry.addInterceptor(testInterceptor1)
                .excludePathPatterns("/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg")
                .addPathPatterns("/**");
    }
}
